<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

    <!--
        Atributy:
            label ... volitelný (odpovídá textu v hint bublině)
            action ... akce po kliknutí
            iconName ... /resources/images/icons/icon-#{iconName}.png
            bean ... pokud je bean="true" tak se místo <a /> použije <h:commandLink action="#{action} />"
        -->

    <ui:composition>
        
        <c:if test="#{empty label}">
            <c:set var="label" value="#{iconName}" />
        </c:if>

        <c:if test="#{empty rendered}">
            <c:set var="rendered" value="true" />
        </c:if>

        <c:choose>
            <c:when test="#{action == 'goHome'}">
                <c:set var="ahref" value="#{request.contextPath}/user/main.jsf" />
            </c:when>
            <c:when test="#{action == 'printPage'}">
                <c:set var="ahref" value="javascript:print();" />
            </c:when>
            <c:otherwise>
                <c:set var="ahref" value="#{request.contextPath}/user/#{action}.jsf" />
            </c:otherwise>
            <!-- Další přijdou sem. -->
        </c:choose>

        <!-- toolbar icon -->
        <c:if test="#{rendered == true}">
            <c:if test="#{empty bean}">
                <li id="#{iconName}">
                    <a href="#{ahref}">
                        <img id="#{iconName}Image" src="#{request.contextPath}/resources/images/icons/icon-#{iconName}.png" alt="#{iconName}" title="#{label}" />
                    </a>

                    <c:if test="#{sideLabel == true}">
                        <a href="#{ahref}">
                            #{label}&nbsp;&nbsp;
                        </a>
                    </c:if>
                </li>
            </c:if>

            <c:if test="#{bean == true}">
                <li id="#{iconName}">
                            <h:commandLink action="#{backingBean[action]}" 
                                           rendered="#{renderedBean[renderedAction]}">
                                <img id="#{iconName}Image" src="#{request.contextPath}/resources/images/icons/icon-#{iconName}.png" alt="#{iconName}" title="#{label}" />
                                <f:ajax execute="#{ajaxExecute}" render="#{ajaxRender}" onevent="showIndicator" />
                            </h:commandLink>
                            <c:if test="#{sideLabel == true}">
                                <h:commandLink action="#{backingBean[action]}"
                                               rendered="#{renderedBean[renderedAction]}">
                                    #{label}
                                    <f:ajax execute="#{ajaxExecute}" render="#{ajaxRender}" onevent="showIndicator" />
                                </h:commandLink>
                            </c:if>
                </li>
            </c:if>
        </c:if>
        
    </ui:composition>
</html>
